package xyz.jpcr.covid19app.Api;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class OverallApiClient {

    private static String BASE_URL = "https://disease.sh/v3/covid-19/";
    private static OverallApiClient overallApiClient;
    private static Retrofit retrofit;

    private OverallApiClient() {
        retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }

    public static void setBaseUrl(String baseUrl) {
        BASE_URL = baseUrl;
    }

    public static synchronized OverallApiClient getInstance() {
        if (overallApiClient == null) {
            overallApiClient = new OverallApiClient();
        }
        return overallApiClient;
    }

    public OverallApiInterface getApi() {
        return retrofit.create(OverallApiInterface.class);
    }
}
